package pl.edu.agh.experts.diseases;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import pl.edu.agh.experts.diseases.commons.Decision;
import pl.edu.agh.experts.diseases.commons.Diseases;
import pl.edu.agh.experts.diseases.commons.IDisease;
import pl.edu.agh.experts.diseases.commons.Symptom;
import pl.edu.agh.experts.diseases.diseases.AcutePericarditis;
import pl.edu.agh.experts.diseases.diseases.Arrhythmia;
import pl.edu.agh.experts.diseases.diseases.CardiacAdiposity;
import pl.edu.agh.experts.diseases.diseases.CardiacAsthma;
import pl.edu.agh.experts.diseases.diseases.Endocarditis;
import pl.edu.agh.experts.diseases.diseases.HeadBloodFlush;
import pl.edu.agh.experts.diseases.diseases.Hypertension;
import pl.edu.agh.experts.diseases.diseases.Hypotension;
import pl.edu.agh.experts.diseases.diseases.IschaemicHeartDisease;
import pl.edu.agh.experts.diseases.diseases.Myocarditis;
import pl.edu.agh.experts.diseases.diseases.Neurosis;

public class DiseaseHolder {
	
	private static DiseaseHolder instance; 

	private final Map<Diseases, IDisease> diseases;

	public DiseaseHolder() {
		instance=this;
		diseases = new HashMap<Diseases, IDisease>();
		diseases.put(Diseases.AcutePericarditis, new AcutePericarditis());
		diseases.put(Diseases.Arrhythmia, new Arrhythmia());
		diseases.put(Diseases.CardiacAdiposity, new CardiacAdiposity());
		diseases.put(Diseases.CardiacAsthma, new CardiacAsthma());
		diseases.put(Diseases.Endocarditis, new Endocarditis());
		diseases.put(Diseases.HeadBloodFlush, new HeadBloodFlush());
		diseases.put(Diseases.Hypertension, new Hypertension());
		diseases.put(Diseases.Hypotension, new Hypotension());
		diseases.put(Diseases.IschaemicHeartDisease, new IschaemicHeartDisease());
		diseases.put(Diseases.Myocarditis, new Myocarditis());
		diseases.put(Diseases.Neurosis, new Neurosis());
	}

	public IDisease getDisease(Diseases disease) {
		return diseases.get(disease);
	}

	public void setAnswer(Symptom symptom, Decision decision) {
		setAnswer(symptom, decision, 0);
	}

	public void setAnswer(Symptom symptom, Decision decision, double weight) {
		for (IDisease disease : diseases.values()) {
			disease.updateStats(symptom, decision, weight);
		}
	}

	public List<IDisease> getAllDiseases() {
		return new LinkedList<IDisease>(diseases.values());
	}

	public static DiseaseHolder getInstance() {
		return instance;
	}
}
